package com.yyh.BookLendSystem.ui;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import com.yyh.BookLendSystem.dao.BookDao;

import org.eclipse.swt.layout.RowLayout;

import java.util.List;
import java.util.Map;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import swing2swt.layout.BorderLayout;
import org.eclipse.swt.widgets.Button;

public class ReaderUI {

	protected Shell shell;
	private BookDao dao = new BookDao();
	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			ReaderUI window = new ReaderUI();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.setSize(660, 584);
		shell.setText("SWT Application");
		shell.setLayout(new BorderLayout(0, 0));
		
		Composite composite = new Composite(shell, SWT.NONE);
		composite.setLayoutData(BorderLayout.CENTER);
		composite.setLayout(new RowLayout(SWT.HORIZONTAL));
		
		
		Composite composite_1 = new Composite(shell, SWT.NONE);
		composite_1.setLayoutData(BorderLayout.EAST);
		RowLayout rl_composite_1 = new RowLayout(SWT.VERTICAL);
		rl_composite_1.marginHeight = 10;
		rl_composite_1.marginWidth = 10;
		composite_1.setLayout(rl_composite_1);
		
		Button btnNewButton = new Button(composite_1, SWT.NONE);
		btnNewButton.setText("我的信息");
		
		Button btnNewButton_1 = new Button(composite_1, SWT.NONE);
		btnNewButton_1.setText("修改密码");
		
		
		////////////////////
		List<Map<String,Object>> books = dao.select(null, null, null);
		for (int i = 0; i < books.size(); i++) {
			new BookCmp(composite,SWT.NONE,books.get(i).get("IMAGE")+"",books.get(i).get("NAME")+"",
					books.get(i).get("ID")+"");
			
		}	
				
	}
}
